package own.stu.jobgib.playown.concurrenceAction.chapter7Cancel;

import java.util.concurrent.TimeUnit;

public class InterruptedDemo {
    public static void main(String[] args) {
        Thread t = new Thread(() ->{
            try {
                TimeUnit.SECONDS.sleep(100);
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().getName() + " -> " + Thread.interrupted());
                // Thread.currentThread().isInterrupted() 中断状态为false, 说明清除当前线程的中断状态
                System.out.println(Thread.currentThread().getName() + " -> isInterrupted: " + Thread.currentThread().isInterrupted());
                e.printStackTrace();
            }
        });

        t.start();
        t.interrupt();
        System.out.println(t.isInterrupted());

    }
}
